package com.cman777.springc.sample.config.idempotence;

import com.cman777.springc.idempotence.IdempotenceClient;
import com.cman777.springc.idempotence.storage.CacheableStorage;
import com.cman777.springc.idempotence.storage.RedissionStorageAdapter;

import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author chenzhicong
 * @time 2020/9/15 14:14
 */
@Configuration
public class IdempotenceConfig {

    private Long cacheSeconds = 60L;

    @Bean
    public CacheableStorage cacheableStorage(RedissonClient redissonClient, MybatisPlusStorageAdapter mybatisPlusStorageAdapter){
        return new CacheableStorage(new RedissionStorageAdapter(redissonClient,cacheSeconds),mybatisPlusStorageAdapter);
    }
    @Bean
    public IdempotenceClient idempotenceClient(CacheableStorage cacheableStorage){
        return new IdempotenceClient(cacheableStorage);
    }


}
